﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //post
            //第一种方法from
            string name1 = Request.Form["TextBox1"];
            string possword1 = Request.Form["TextBox2"];
            //第二种方法PreviousPage
            string name2 = "";
            string possword2 = "";
            Response.Write($"from==>  你的用户名是{name1},密码是{possword1}"+"<br/>");
            if (PreviousPage!=null)
            {
                TextBox nameBox = (TextBox)PreviousPage.FindControl("TextBox1");
                TextBox posswordBox = (TextBox)PreviousPage.FindControl("TextBox2");
                if (nameBox!=null)
                {
                     name2 = nameBox.Text;
                }
                if (possword1!=null)
                {
                     possword2 = posswordBox.Text;
                }
                
            }
            Response.Write($"PreviousPage==>  你的用户名是{name2},密码是{possword2}" + "<br/>");
            //第三种方法Params
            string name3 = Request.Params["TextBox1"];
            string possword3 = Request.Params["TextBox2"];
            Response.Write($"Params==>  你的用户名是{name3},密码是{possword3}" + "<br/>");
            //get
            //第四种方法QueryString
            string name4 = Request.QueryString["n"];
            string possword4 = Request.QueryString["p"];
            Response.Write($"QueryString==>  你的用户名是{name4},密码是{possword4}" + "<br/>");
            //第五种方法Params
            string name5 = Request.Params["n"];
            string possword5 = Request.Params["p"];
            Response.Write($"Params==>  你的用户名是{name5},密码是{possword5}" + "<br/>");
        }
    }
}